#if !defined(SerializeHeader)
#define SerializeHeader

#include <iostream>

class Serializer {
public:
  virtual void serialize (const void*, int) const = 0;
};

class istreamSerializer {
public:
  istreamSerializer (std::istream &is) :
    istream (is) {
  }

  void serialize (const void *buf, int size) const {
    istream.read ((char*) buf, size);
  }

  std::istream &istream;
};

class ostreamSerializer {
public:
  ostreamSerializer (std::ostream &os) :
    ostream (os) {
  }

  void serialize (const void *buf, int size) const {
    ostream.write ((char*) buf, size);
  }

  std::ostream &ostream;
};

template<typename T>
void serialize (const Serializer &s, const T &t) {
  s.serialize (&t, sizeof(T));
}

#endif
